package com.jml.service;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class ServiceRenewal {
    private ScheduledExecutorService scheduledService = Executors.newSingleThreadScheduledExecutor();

    public void start() {
        scheduledService.scheduleAtFixedRate(new ServiceRenewalThread(), 3, 3, TimeUnit.SECONDS);
    }

    @Autowired
    private RegisterService registerService;

    /**
     * 服务续约线程
     */
    class ServiceRenewalThread implements Runnable {
        @Override
        public void run() {
            registerService.renewal();
        }
    }
}
